/*
    Copyright 2008, 2009, 2010 Brightworks, Inc.
    
    This file is part of Language Mentor.
    
    Language Mentor is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    Language Mentor is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with Language Mentor.  If not, see <http://www.gnu.org/licenses/>.
*/
package com.langcollab.languagementor.util
{
    import com.brightworks.util.Debug;
    import com.langcollab.languagementor.constant.Constant_Misc;
    
    import flash.system.Capabilities;

    public class Utils_System
    {
        public static var _bInitialized:Boolean;
        
        
        // ****************************************************
        //
        //          Getters / Setters
        //
        // ****************************************************
        
        private static var _appHeight:int;
        public static function get appHeight():int 
        {
            init();
            return _appHeight;
        }
        
        private static var _appWidth:int;
        public static function get appWidth():int 
        {
            init();
            return _appWidth;
        }
        
        // ****************************************************
        //
        //          Constructor
        //
        // ****************************************************
        
        public function Utils_System(enforcer:SingletonEnforcer):void {};  // Should never be used
        
        // ****************************************************
        //
        //          Public Methods
        //
        // ****************************************************
        
        public static function isRunningOnDesktop():Boolean
        {
            var operatingSystem:String = Capabilities.os;
            var result:Boolean = false;
            if (operatingSystem.indexOf("Windows") != -1)
            {
                switch (operatingSystem)
                {
                    case "Windows XP":
                    case "Windows 2000":
                    case "Windows NT":
                    case "Windows 7":
                        result = true;
                        break;
                    default:
						Debug.error_Fatal(Constant_Misc.APP_NAME + " does not currently support this operating system. (" + operatingSystem + ")");
                }
            }
            else if (operatingSystem.indexOf("MacOS") != -1)
            {
                result = true;
            }   
            else if (operatingSystem.indexOf("Linux") != -1)
            {
                switch (operatingSystem)
				{
					case "Linux 2.6.32.9-g55626e1":
						// Android 2.2
						break
					default:
						throw new Error("Utils_System.isRunningOnDesktop(): No case for " + operatingSystem);

				}
            }   
            return result;
        }

        // ****************************************************
        //
        //          Private Methods
        //
        // ****************************************************
        
        private static function init():void {
            if (!_bInitialized) {
                determineAppDimensions();
            }
        }
        
        private static function determineAppDimensions():void
        {
            var operatingSystem:String = Capabilities.os;
            var bMobileDevice:Boolean = true;
            if (operatingSystem.indexOf("Windows") != -1)
            {
                switch (operatingSystem)
                {
                    case "Windows XP":
                    case "Windows 2000":
                    case "Windows NT":
                        bMobileDevice = false;
                        break;
                    default:
						Debug.error_Fatal(Constant_Misc.APP_NAME + " does not currently support this operating system. (" + operatingSystem + ")");
                }
            }
            else if (operatingSystem.indexOf("MacOS"))
            {
                bMobileDevice = false;
            }   
            else if (operatingSystem.indexOf("Linux"))
            {
				Debug.error_Fatal(Constant_Misc.APP_NAME + " does not currently support this operating system. (" + operatingSystem + ")");
            }   
            if (bMobileDevice)
            {
                _appHeight = Capabilities.screenResolutionY;
                _appWidth = Capabilities.screenResolutionX;
            }
            else
            {
                _appHeight = 220;
                _appWidth = 360;
            }
        }
}
}

class SingletonEnforcer {}